using System;
using System.Collections.Generic;
using System.Text;
using Lizk.SimpleHUD;

namespace SharpMedia.Controls
{
    public class HUDCenterList : HUDAlphaList
    {
        public HUDCenterList(SizeS itemSize)
            : base(itemSize, true)
        {
            SetStartIndex((int)(Bounds.Width / itemSize.Width / -2f), false);
        }

        public PointS CenterOffset { get; set; }

        public override void ResizeMove(RectangleS oldRect, RectangleS newRect)
        {
            base.ResizeMove(oldRect, newRect);
            Offset = new PointS((newRect.Width % itemSize.Width) / 2f + itemSize.Width / 2f * (((int)(newRect.Width / itemSize.Width) % 2) == 0 ? -1 : 0), 0) + CenterOffset;
            SetStartIndex((int)(newRect.Width / itemSize.Width / -2f) + SelectedIndex, true);
        }


        public override int SelectedIndex
        {
            get
            {
                return selectedIndex;
            }
            set
            {
                if (selectedIndex != value)
                {
                    SetSelectedIndex(value, true);

                    StartIndex = (int)(Bounds.Width / itemSize.Width / -2f) + SelectedIndex;

                }
            }
        }

    }
}
